import React, {Component} from 'react';
import { ScrollView, StyleSheet, View,Dimensions } from 'react-native';
import { Button, Drawer, List, WhiteSpace } from 'antd-mobile-rn';
import SplashScreen from 'react-native-splash-screen';
import HttpTemp from "../../../preset/func/http/httptemp"

/**
 * 本地组件
 */
import {Page, Content, Svg, Text, Label, Image, ScrollX, ScrollY, ItemX, ItemY, Row, Header, Footer, Float, Wrap, Between, Touch, Hand, ButtonOpacity, ButtonLight, TouchOpacity, TouchLight} from '../../../library'
import {Icon1} from '../../../preset';

/**
 * 项目库
 */
// import Group from '../../project/style/group';



export default class Test extends Component {

    constructor(props){
        super(props)
        this.state = {
            h : Dimensions.get('window').height,
            list:[]
        }
    }
  

    /**
     * didMount
     */
    componentDidMount(){
        // SplashScreen.hide();
        HttpTemp.get({
            url:"page/guest/codelist.php",
            success:(res) => {
                let data = res.data;
                this.setState({
					list:data
                })
            }
        })

    }


  render() {

    return (
      <View style={{backgroundColor:'rgba(0,0,0,.7)',flex:1}}>
            <View style={{height: this.state.h,backgroundColor:'#fff',width:300, marginBottom:10}}>
                <Content bg='#f0f0f0'>
                    <Row h='30' y='center' px='10'>
                        <Text>来访记录</Text>
                    </Row>


                    {this.state.list.map((item,index)=>{
                        return(
                            <View style={{backgroundColor:'#fff', marginLeft:10, marginRight:10, borderRadius:4, padding:10}}>
                            <Row h='40' y='center'>
                                <Between>
                                    <Text>{ item.subdistrict_name }</Text>
                                    <Text color='#21ac43'>{ item.set_use_times <= tem.count_use_times ||  new Date().getTime()/1000 <= tem.time_over ? '可使用':'已作废'  }</Text>
                                </Between>
                            </Row>
                            <Row h='40' y='center'>
                                <ItemX y='center'>
                                    <Image source={require('../../../assets/help.png')} w='10' h='10'/>
                                    <Text>{ new Date(parseInt(item.created) * 1000).toLocaleString().substr(0,17) }</Text>
                                </ItemX>
                            </Row>
                            <Row h='40' y='center'>
                                <Between>
                                    <ItemX y='center'>
                                        <Image source={require('../../../assets/help.png')} w='10' h='10'/>
                                        <Text>使用码：{item.set_code }</Text>
                                    </ItemX>
                                    <Hand>
                                        <Text bg='#21ac43' color='#fff' ra='3' px='10' py='2'>复制</Text>
                                    </Hand>
                                </Between>
                            </Row>
                        </View>
    
                        )
                    })}
                    
                </Content>
            </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
    container: {
      flex: 1,
    },
  });